$(document).ready(function () {

    InitBinding();

});



function InitBinding() {

    console.log($('#successfulEdit').val());

	//On submit on add page, submit the add and shows the success
	//page it the edit was successful, otherwise add page is shown again including
	//validation errors
    $("#Submit").click(function (e) {
        e.preventDefault();
        CallPostRequestForChangeSetting();
    });
}



//Ajax request to load in next page of results
function CallPostRequestForChangeSetting() {

 
    var formData = $("#ChangeSettingsForm").serialize();

    $.post("/Settings/ChangeSettings", formData, function (response) {

 
        $("#AjaxSettingsContents").replaceWith(response);
        InitBinding();

        var successfulAdd = $('#successfulEdit').val();
        if (successfulAdd == "True") {
            showOkDialog('Sucessfully saved your settings', 180, 'Information');
        }
        else {
            showOkDialog('Could not update your user settings', 180, 'Error');
        }
    });
	return false;
}


